package com.codegravity.mobile.expensms;

import java.util.List;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class ImageAdapter extends BaseAdapter {
	int mGalleryItemBackground;
	private Context mContext;
	LayoutInflater inflator;
	private List<List<Float>> e_amntMasterlst = null;
	private List<Float> weeklyAvg = null, mnthAvg = null;
	private List<List<Integer>> e_cntMasterlist = null;
	private List<String> weeksList;
	private static int isSun;

	public ImageAdapter(Context c, LayoutInflater inflator,
			List<List<Float>> amount_lst, List<List<Integer>> cnt_lst,
			List<String> weeks, List<Float> e_weekly, List<Float> e_monthly) {
		SharedPreferences myPrefs = c.getSharedPreferences("SMSExpense",
				Context.MODE_WORLD_READABLE);
		isSun = myPrefs.getBoolean("weekSun", false) ? 0 : 1;

		this.weeklyAvg = e_weekly;
		this.mnthAvg = e_monthly;
		this.e_amntMasterlst = amount_lst;
		this.e_cntMasterlist = cnt_lst;
		this.weeksList = weeks;
		mContext = c;
		this.inflator = inflator;
		TypedArray a = c.obtainStyledAttributes(R.styleable.HelloGallery);
		mGalleryItemBackground = a.getResourceId(
				R.styleable.HelloGallery_android_galleryItemBackground, 0);
		a.recycle();
	}

	public int getCount() {
		return e_amntMasterlst.size();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ExpenseBarChart chart = new ExpenseBarChart(mContext,
				e_amntMasterlst.get(position), e_cntMasterlist.get(position),
				weeksList.get(position), weeklyAvg.get(position),
				mnthAvg.get(position), 0, isSun);
		// chart.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
		// LayoutParams.FILL_PARENT));
		return chart;
	}
}